/**
 * @class Ext.app.QueriesPanel
 * @extends Ext.panel.Panel
 */
Ext.define('Ext.app.QueriesPanel', {
    extend: 'Ext.tree.Panel',
    alias: 'widget.queriesPanel',
    autoScroll: true,
    border: false,
    store: Ext.create('Ext.data.TreeStore', {
        proxy: {
            type: 'ajax',
            url: 'GetQnodes.jsp'
        },
        root: {
            text: '',
            id: 'root',
            expanded: true
        },
        folderSort: true,
        sorters: [{
            property: 'text',
            direction: 'ASC'
        }]
    }),
    viewConfig: {
        plugins: {
            ddGroup: 'tree-to-form',
            ptype: 'treeviewdragdrop',
            enableDrop: false
        }
    },
    rootVisible: false,
    useArrows: true,
    listeners: {
        itemdblclick: function(tree, record, item, index, e, eOpts) {
            if(record.get("leaf")) {
                this.loadQueryFunction.call(null, record.get("id"));
            }
        }
    },
    
    constructor: function (loadQueryFunction) {
        this.loadQueryFunction = loadQueryFunction;
        
        this.callParent(arguments);
    }
});
